#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int nextval[maxn];

int main()
{
	string s,p;
	cin >> s >> p;
	bool found=false;

	nextval[0]=0;
	for(int i=1,j=0;i<p.size();i++)
	{
		while(j>0&&p[j]!=p[i])
		{
			j=nextval[j-1];
		}
		if(p[j]==p[i])
		{
			j++;
		}
		nextval[i]=j;
	}

	for(int i=0,j=0;i<s.size();i++)
	{
		while(j>0&&s[i]!=p[j])
		{
			j=nextval[j-1];
		}
		if(s[i]==p[j])
		{
			j++;
		}
		if(j==p.size())
		{
			found=true;
			cout << i-p.size()+1 << endl;
			j=nextval[j-1];
		}
	}

	if(found==false)
	{
		cout << "-1" << endl;
	}
	return 0;
}
